package com.zcr.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zcr.mapper.SellrecordsMapper;
import com.zcr.pojo.Jinhuorecords;
import com.zcr.pojo.Sellrecords;
import com.zcr.service.SellrecordsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;

/**
 * @version 1.0
 * @author： 张诚
 * @date： 2021-03-27 09:04
 */
@Service("SellrecordsService")
public class SellrecordsServiceImpl extends ServiceImpl<SellrecordsMapper, Sellrecords> implements SellrecordsService {

    @Resource
    private SellrecordsMapper sellrecordsMapper;

    @Override
    public Page<Sellrecords> getbyjinhuoxinxi(String drugname, int pageNo, int pageSize) {
        QueryWrapper<Sellrecords> wrapper=Wrappers.query();
        wrapper.like(!StringUtils.isBlank(drugname),"drugname",drugname);
        Page<Sellrecords> page = new Page<>(pageNo,pageSize);
        return sellrecordsMapper.selectPage(page,wrapper);
    }

    @Override
    public boolean add(Sellrecords sellrecords) {
        return sellrecordsMapper.insert(sellrecords)>0;
    }

    public void deleteAllDruginfo(String[] ids) {
        sellrecordsMapper.deleteBatchIds(Arrays.asList(ids));
    }
}
